package org.nepu.scr.indexrate.converter.drillingrate.keydevice.fixedwellsystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.fixedwellsystem.FixedWell;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class FixedWellConverter implements AttributeConverter<FixedWell, String> {
    @Override
    public String convertToDatabaseColumn(FixedWell fixedWell) {
        return JSONUtil.toJsonStr(fixedWell);
    }

    @Override
    public FixedWell convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, FixedWell.class);
    }
}
